package data.generator;

import java.util.ArrayList;
import java.util.Random;

import model.Book;

public class BookGenerator {

	private static String[] authors = { "Wrox", "O'Reilly" };
	private static String[] topics = { "C# .net", "Visual Basic .net", "C", "Python", "Haskell" };
	private static String[] levels = { "for dummies", "for intermediate developers", "for experienced developers" };
	
	/* Make sure the class can't be instantiated */
	private BookGenerator() {
	}
	
	public static ArrayList<Book> generateBooks(int amount) {
	
		// Create list of books
		ArrayList<Book> books = new ArrayList<Book>();
		
		// Fill list
		for (int i = 0; i < amount; i++) {
			Book book = generateBook();
			books.add(book);
		}
		
		// Return list
		return books;
	}
	
	public static Book generateBook() {
		
		String author;
		String level;
		String topic;
		
		Random random = new Random();
		
		// Create a random author
		author = authors[random.nextInt(authors.length)];
		
		// Create a random title
		topic = topics[random.nextInt(topics.length)];
		level = levels[random.nextInt(levels.length)];
		
		// Create new book
		Book book = new Book();
		
		// Set book properties
		book.setAuthor(author);
		book.setTitle(topic + " " + level);
		
		// Return result
		return book;
	}
}